import Taro from '@tarojs/taro'
import { prefix } from '../utils'

export function add(payload, callback) {
    return () => {
        const userInfo = Taro.getStorageSync('userInfo')
        
        Object.assign(payload, {...userInfo})
        Taro.request({
            url: `${prefix}/api/v1/apply`,
            data: payload,
            method: 'POST',
            header: { 'content-type': 'application/json' }
        })
        .then(results => {
            const { data = {} } = results || {}
            if(callback) callback(data)
        })
    }
}